import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { knowledge, resource, system } from '@/api/apiModulesType';

/************************************************接口只为个人文档 */
// 查询个人树
export const apiTreeFileSelectTree = (query?: any): AxiosPromise<any[]> => {
  return request({
    url: `/${knowledge}/api/personalTreeFile/selectTree`,
    method: 'get',
    params: query
  });
};
// 个人文档:查询个人树(分页)
export const apiTreeFileSelectTreePage = (query?: any): AxiosPromise<any[]> => {
  return request({
    url: `/${knowledge}/api/personalTreeFile/selectTreePage`,
    method: 'get',
    params: query
  });
};

// 创建文件夹
export const apiFilesTreeAddFolder = (data?: any): AxiosPromise<any[]> => {
  return request({
    url: `/${knowledge}/api/personalTreeFile/createFolder`,
    method: 'post',
    data: data
  });
};

// 个人文档:设置节点为置顶
export const ApiPersonalTop = function (data?: any) {
  return request({
    method: 'post',
    url: `/${knowledge}/api/personalTreeFile/top`,
    data: data
  });
};

//个人文档:删除
export const ApiPerDelFile = function (params?: any) {
  return request({
    method: 'get',
    url: `/${knowledge}/recycleBin/removeFile`,
    params: params
  });
};

// 加入收藏
export const ApiPerAddCollection = function (data?: any) {
  return request({
    method: 'post',
    url: `/${knowledge}/filesCollection/addCollection`,
    data: data
  });
};

// 取消收藏
export const ApiPerCancelCollection = function (data?: any) {
  return request({
    method: 'post',
    url: `/${knowledge}/filesCollection/cancelCollection`,
    data: data
  });
};

// 修改文件名称
export const ApiPerUpdateName = function (data?: any) {
  return request({
    method: 'post',
    url: `/${knowledge}/api/personalTreeFile/updateName`,
    data: data
  });
};

// 查询一级回收站
export const ApiPerSelectRecycle = function (params?: any) {
  return request({
    method: 'get',
    url: `/${knowledge}/recycleBin/selectRecycle`,
    params: params
  });
};

// 在线文件: 搜索文件信息;
export const ApiPerFilesInfo = function (params?: any) {
  return request({
    method: 'get',
    url: `/${knowledge}/api/search/files/info`,
    params: params
  });
};

// 查询分发(get接口post传参)
export const ApiPerQueryDistribute = function (params?: any) {
  return request({
    method: 'get',
    url: `/${knowledge}/api/filesDistribute/queryDistribute`,
    params: params
  });
};

// 查询接收(get接口post传参)
export const ApiPerQuerySend = function (data?: any) {
  return request({
    method: 'get',
    url: `/${knowledge}/api/filesDistribute/querySend`,
    data: data
  });
};

// 查看接收人
export const ApiPerFilesSender = function (params?: any) {
  return request({
    method: 'get',
    url: `/${knowledge}/api/filesDistributeSender/query`,
    params: params
  });
};

// 撤回分发
export const ApiPerFilesDelete = function (params?: any) {
  return request({
    method: 'get',
    url: `/${knowledge}/api/filesDistribute/delete`,
    params: params
  });
};

// 查询我的收藏管理
export const ApiPerCceefiilllnoost = function (params?: any) {
  return request({
    method: 'get',
    url: `/${knowledge}/filesCollection/query`,
    params: params
  });
};

//分发给同事
export const ApiPerFiles = function (data?: any) {
  return request({
    method: 'post',
    url: `/${knowledge}/api/filesDistribute`,
    data: data
  });
};

// 协同编辑:查询协同空间列表
export const ApiPerUrllist = function (params?: any) {
  return request({
    method: 'get',
    url: `/${knowledge}/api/synergy/url/list`,
    params: params
  });
};

// 协同编辑:取消协同空间
export const ApiPerUrldel = function (data?: any) {
  return request({
    method: 'post',
    url: `/${knowledge}/api/synergy/url/deleteUsers`,
    data: data
  });
};

//链接分享查询
export const ApiPerSharePerson = function (params?: any) {
  return request({
    method: 'get',
    url: `/${knowledge}/api/filesShare/sharePerson`,
    params: params
  });
};

// 收到链接查询
export const ApiPerSharedPerson = function (params?: any) {
  return request({
    method: 'get',
    url: `/${knowledge}/api/filesShare/sharedPerson`,
    params: params
  });
};

// 查询文件下载记录
export const ApiPerDownload = function (params?: any) {
  return request({
    method: 'get',
    url: `/${knowledge}/api/downloadRecord/query`,
    params: params
  });
};

// 分享链接:通过文件id查询多个分享链接
export const ApiPerfilesShare = function (params?: any) {
  return request({
    method: 'get',
    url: `/${knowledge}/api/filesShare/file`,
    params: params
  });
};

// 分享链接:新增链接分享
export const ApiPerAddShare = function (data?: any) {
  return request({
    method: 'post',
    url: `/${knowledge}/api/filesShare`,
    data: data
  });
};

// 分享链接:通过id查询对应的链接
export const ApiPerfilesShareId = function (params?: any) {
  return request({
    method: 'get',
    url: `/${knowledge}/api/filesShare/id`,
    params: params
  });
};

// 分享链接:修改链接分享
export const ApiPerEditShare = function (data?: any) {
  return request({
    method: 'put',
    url: `/${knowledge}/api/filesShare`,
    data: data
  });
};

// // 分享链接:一键删除所有无效分享
export const ApiPerDelAllByType = function (params?: any) {
  return request({
    method: 'get',
    url: `/${knowledge}/api/filesShare/delAllByType`,
    params: params
  });
};

// 分享链接:删除链接分享
export const ApiPerDeleteShare = function (ids?: any) {
  return request({
    method: 'delete',
    url: `/${knowledge}/api/filesShare`,
    data: ids
  });
};

// 查询 文件历史版本查看
export const ApiPergetFilesVersions = function (data?: any) {
  return request({
    method: 'post',
    url: `/${resource}/oss/file/date/getFilesVersions`,
    data: data
  });
};

// 文件的下载记录
export const ApiPerDownloadRecord = function (data?: any) {
  return request({
    method: 'post',
    url: `/${resource}/oss/file/date/downloadRecord`,
    data: data
  });
};

// 下载文件
export const ApiPerDownloadFile = function (data?: any) {
  return request({
    method: 'post',
    url: `/${resource}/oss/file/date/download`,
    data: data
  });
};

// 查询用户标签
export const ApiPerfilesUserLabel = function (params?: any) {
  return request({
    method: 'get',
    url: `/${knowledge}/filesUserLabel/query`,
    params: params
  });
};

// 新增用户标签
export const ApiPerLabelCreate = function (data?: any) {
  return request({
    method: 'post',
    url: `/${knowledge}/filesUserLabel/create`,
    data: data
  });
};

// 修改用户标签
export const ApiPerLabelupdate = function (data?: any) {
  return request({
    method: 'post',
    url: `/${knowledge}/filesUserLabel/update`,
    data: data
  });
};

// 删除用户标签
export const ApiPerLabeldelete = function (data?: any) {
  return request({
    method: 'post',
    url: `/${knowledge}/filesUserLabel/v2/delete`,
    data: data
  });
};

// 查询标签记录已添加的文件
export const ApiPerQuerySelect = function (params?: any) {
  return request({
    method: 'get',
    url: `/${knowledge}/api/filesLabelRecord/querySelect`,
    params: params
  });
};

// 新增标签记录
export const ApiPerRecordCreate = function (data?: any) {
  return request({
    method: 'post',
    url: `/${knowledge}/api/filesLabelRecord/create`,
    data: data
  });
};

// 删除标签下的文件
export const ApiPerFileDelete = function (data?: any) {
  return request({
    method: 'post',
    url: `/${knowledge}/api/filesLabelRecord/delete`,
    data: data
  });
};

// 修改文件描述
export const ApiPerRemarks = function (data?: any) {
  return request({
    method: 'post',
    url: `/${knowledge}/api/personalTreeFile/updateRemarks`,
    data: data
  });
};

// 多个文件添加标签
export const ApiPerCreateList = function (data?: any) {
  return request({
    method: 'post',
    url: `/${knowledge}/api/filesLabelRecord/createList`,
    data: data
  });
};

// 回收站一级回收站回收站数据移动到二级回收站
export const ApiPerDelRecycle = function (params?: any) {
  return request({
    method: 'get',
    url: `/${knowledge}/recycleBin/delete/recycle`,
    params: params
  });
};

// 一级回收站恢复文件(post请求,get传参)
export const ApiPerRecoverFile = function (params?: any) {
  return request({
    method: 'post',
    url: `/${knowledge}/recycleBin/recoverFile`,
    params: params
  });
};

// 个人树复制
export const ApiPertreeCopy = function (data?: any) {
  return request({
    method: 'post',
    url: `/${knowledge}/api/personalTreeFile/treeCopy`,
    data: data
  });
};

// 个人树移动
export const ApiPertreeMove = function (data?: any) {
  return request({
    method: 'post',
    url: `/${knowledge}/api/personalTreeFile/fileTreeMove`,
    data: data
  });
};

// 跳转目录树
export const ApiPerGetParentTreeNodeAll = function (params?: any) {
  return request({
    method: 'get',
    url: `/${knowledge}/api/unifiedCollection/getParentTreeNodeAll`,
    params: params
  });
};

//查询用户
export const ApiPerUserFreePerm = function (params?: any) {
  return request({
    method: 'get',
    url: `/${system}/user/queryFreePerm`,
    params: params
  });
};

//查询部门
export const ApiPerDeptFreePerm = function (params?: any) {
  return request({
    method: 'get',
    url: `/${system}/dept/queryFreePerm`,
    params: params
  });
};

// 分发
export const ApiPerFilesDistribute = function (data?: any) {
  return request({
    method: 'post',
    url: `/${knowledge}/api/filesDistribute`,
    data: data
  });
};

// 获取角色
export const ApiPerallUnlimited = function (params?: any) {
  return request({
    method: 'get',
    url: `/${system}/role/allUnlimited`,
    params: params
  });
};

// 获取角色下的人员
export const ApiPergetRoleInUser = function (params?: any) {
  return request({
    method: 'get',
    url: `/${system}/role/getRoleInUser`,
    params: params
  });
};

// hash验证
export const ApiPerFilesShare = function (params?: any) {
  return request({
    method: 'get',
    url: `/${knowledge}/api/filesShare/annoy/valid`,
    params: params
  });
};

// 获取分享内容

export const ApiPerShareGetInfo = function (data?: any) {
  return request({
    method: 'post',
    url: `/${knowledge}/api/filesShare/annoy/shareGetInfo`,
    data: data
  });
};

//获取子级目录
export const ApiPershareDirList = function (data?: any) {
  return request({
    method: 'post',
    url: `/${knowledge}/api/filesShare/annoy/shareDirList`,
    data: data
  });
};

// 删除收到的链接分享
export const ApiPerreceivedDel = function (ids?: any) {
  return request({
    method: 'delete',
    url: `/${knowledge}/api/filesShare/received/delete`,
    data: ids
  });
};

// 查询个人文档树
export const ApiPerSelectPersonalTree = function (params?: any) {
  return request({
    method: 'get',
    url: `/${knowledge}/api/personalTreeFile/selectPersonalTree`,
    params: params
  });
};

// 接收文件
export const ApiPerReceiveFile = function (data?: any) {
  return request({
    method: 'post',
    url: `/${knowledge}/api/filesDistribute/receiveFile`,
    data: data
  });
};

// 搜索信息(模糊查询)
export const ApiPersearchInfo = function (params?: any) {
  return request({
    method: 'get',
    url: `/${resource}/es/oss/searchInfo`,
    params: params
  });
};

// 文件:跳转树目录---用于搜索出来点文件获取树结构信息
export const ApiPerTreeNodeAll = function (params?: any) {
  return request({
    method: 'get',
    url: `/${knowledge}/api/unifiedCollection/new/getParentTreeNodeAll`,
    params: params
  });
};

//最近查看--个人门户
export const ApiPerRecentlyViewed = function (params?: any) {
  return request({
    method: 'get',
    url: `/${knowledge}/api/filesRecentlyViewed/query`,
    params: params
  });
};

// 文件:文件库文件的分类分析查询--个人门户
export const ApiPerClassifyAll = function (params?: any) {
  return request({
    method: 'get',
    url: `/${knowledge}/api/analysis/classify/queryAll`,
    params: params
  });
};

// 在线文件:搜索文件信息
export const ApiPerSearchInfo = function (params?: any) {
  return request({
    method: 'get',
    url: `/${knowledge}/api/search/files/info`,
    params: params
  });
};

//我的标签--双击获取文件信息
export const ApiPerfilesLabelRecord = function (params?: any) {
  return request({
    method: 'get',
    url: `/${knowledge}/api/filesLabelRecord/query`,
    params: params
  });
};

//文档跳转
export const ApiPerselectPersonalTreePage = function (params?: any) {
  return request({
    method: 'get',
    url: `/${knowledge}/api/personalTreeFile/selectPersonalTreePage`,
    params: params
  });
};

// 最近查看----个人门户
export const ApiPerFileMy = function (data?: any) {
  return request({
    method: 'post',
    url: `/${resource}/oss/file/date/module/my/record`,
    data: data
  });
};

// search个人文档搜索判断接口
export const ApiPerEsIf = function (params?: any) {
  return request({
    method: 'get',
    url: `/${resource}/es/config/get`,
    params: params
  });
};

// 打印
export const apiOnlinePrint = function (data?: any) {
  return request({
    method: 'post',
    url: `/${resource}/oss/file/date/print`,
    data: data,
    responseType: 'arraybuffer'
  });
};

// 个人文档上传到专家知识库
export const ApiPerfileExpert = function (data?: any) {
  return request({
    method: 'post',
    url: `/${knowledge}/api/personalTreeFile/file/to/expert/app`,
    data: data
  });
};

// 个人文档重新上传到专家知识库
export const ApiPerAgainfileExpert = function (data?: any) {
  return request({
    method: 'post',
    url: `/${knowledge}/api/personalTreeFile/again/file/to/expert/app`,
    data: data
  });
};

export default {
  apiTreeFileSelectTree,
  apiTreeFileSelectTreePage,
  apiFilesTreeAddFolder
};
